package br.com.ozsolucoes.filters;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet("/imagem.jpg")
public class ImagemServlet extends HttpServlet {

	private static final long serialVersionUID = 6017430953321332937L;

	@Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	HttpServletRequest req = (HttpServletRequest) request;
		HttpSession session = req.getSession();
		byte[] imagem = (byte[]) session.getAttribute("imagem");
        response.setContentType("image/jpeg");
        response.setContentLength(imagem.length);
        response.getOutputStream().write(imagem);
    }

}